package com.sinopec.basemodule.resultcontract

/**
 * 双向的契约
 */
class BiDirectionalFragmentContract<Request, Response>(
    val key: String,
    req: BundleAble<Request>,
    res: BundleAble<Response>,
) {

    val request: UnIdirectionalFragmentContract<Request> =
        UnIdirectionalFragmentContract(
            key + "request",
            req,
        )

    val response: UnIdirectionalFragmentContract<Response> =
        UnIdirectionalFragmentContract(
            key + "response",
            res
        )
}

/**
 * 通过key创建 fragment 这个key必须是arouter的路由路径
 */
fun <Req, Res> BiDirectionalFragmentContract<Req, Res>.createFragment() = createFragment(key)